<?php
namespace Admin\Controller;
use admin\Controller\BaseController;
class IndexController extends BaseController {
	public function index(){
		$this->redirect('HighLevel/lists');
	}
	public function changePassword()
	{
		if(IS_POST){
			$old_password = I('old_password','','md5');
			$new_password = I('new_password','','md5');
			$map['id']    = session['admin_id'];
			$admin = M('admin')->where($map)->find();
			if($old_password === $admin['password']){
				$admin = M('admin')->where($map)
				->setField('password',$new_password);
				if($admin !== false){
					$res['status'] = 1;
					$res['message'] = '更改成功';
					$this->ajaxReturn($res);
				}else{
					$res['status'] = 0;
					$res['message'] = '更改失败';
					$this->ajaxReturn($res);
				}
			}else{
				$res['status'] = 0;
				$res['message'] = '更改失败，原始密码错误';
				$this->ajaxReturn($res);
			}
		}else{
			$this->display();
		}
	}
}